package com.rpc.demo.consumer;


import com.rpc.demo.common.zookeeper.ServiceSubscribe;
import com.rpc.demo.consumer.proxy.ConsumerProxy;
import com.rpc.demo.service.IBookService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Author: ZhaoJie
 * @Date: 2022/4/7
 * @Description:
 * @Modify: ===================================================
 * Modifier        Modifytime        Description
 * ===================================================
 */

public class User {

    /**
     *  日志实例
     */
    private static Logger logger = LoggerFactory.getLogger(User.class);

    public static void main(String[] args) throws InterruptedException {
        //在注册中心订阅服务, 获取服务所在的url, 然后通过代理远程调用服务
        ServiceSubscribe serviceSubscribe = new ServiceSubscribe();
        // 创建代理对象处理器
        ConsumerProxy customerProxy = new ConsumerProxy(serviceSubscribe);
        // 获取RPC代理
        IBookService service = (IBookService) customerProxy.getBean(IBookService.class, "BookService");
        // 远端调用
        for (;; ) {
            Thread.sleep(2 * 1000);
            Object bookInfo = service.getBookInfo(1);
            logger.info(String.valueOf(bookInfo));
        }

    }

}
